﻿<?php
ignore_user_abort(TRUE);
require_once("./interface.php");
require_once("./utils.php");
require_once("./interface.php");
require_once("./TechnicFunc.php");
require_once("./SoldierFunc.php");
require_once("./HotelFunc.php");
require_once("./OfficeFunc.php");
require_once("./MarketFunc.php");
require_once("./UnionFunc.php");
require_once("./StoreFunc.php");
require_once("./TroopFunc.php");
require_once("./global.php");
require_once("./report.php");

//mysql_connect()函数
$con = mysql_connect("127.0.0.1","root","111111");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("sanguo1", $con);//链接数据库
function HandleUsertasks()//定义任务刷新队列
{
mysql_query("DELETE from sys_user_task where tid>=11001&&tid<=14009 ");


//======================公士以上玩家可以做史诗任务
$ss_user_juwei=sql_fetch_into_arrays("select * from sys_user where nobility>=1");//cfg_user 读取爵位达到公士或者以上的玩家
$j=0;
while($ss_user_juwei['uid'][$j]!="")
{
    $ss_uid=$ss_user_juwei['uid'][$j];
    $ss_task=sql_fetch_into_arrays("select * from cfg_task where id>=11001&&id<=14009");//cfg_task 读取史诗任务
   for ($i=0;$ss_task['id'][$i]!="";$i=$i+1)
	 {
      $ss_id=$ss_task['id'][$i];
      mysql_query("INSERT INTO sys_user_task (uid,tid,state) 
      VALUES ('$ss_uid', '$ss_id', '0')");
     // echo $ss_uid."---".$ss_id."<br>";

	 }
	
   $j=$j+1;

 }

//=========================公士以上玩家可以做中秋任务
 $ss_user_juwei=sql_fetch_into_arrays("select * from sys_user where nobility>=1");//cfg_user 读取爵位达到公士或者以上的玩家
$j=0;
/*$timenow=date("Y.m.d h:i:s");
 $r_month=date(m);
 $r_day=date(d);
  */
//while($r_month=8&&$r_day>=8&&$r_day<=18&&$ss_user_juwei['uid'][$j]!="")
    while($ss_user_juwei['uid'][$j]!="")
{ 
mysql_query("DELETE from sys_user_task where tid>=100001&&tid<=100011 ");

    $ss_uid=$ss_user_juwei['uid'][$j];
    $ss_task=sql_fetch_into_arrays("select * from cfg_task where id>=100001&&id<=100011");//cfg_task 读取中秋任务
   for ($i=0;$ss_task['id'][$i]!="";$i=$i+1)
	 {
      $ss_id=$ss_task['id'][$i];
      mysql_query("INSERT INTO sys_user_task (uid,tid,state) 
      VALUES ('$ss_uid', '$ss_id', '0')");
	 }
	
   $j=$j+1;

 }

}
 mysql_close($con);
?>



